let arr = [2,2,2,2,5,5,5,8]
let k = 3
let threshold = 4
function numOfSubarrays(arr, k, threshold) {
    let sum = 0
    for(let i = 0;i<k;i++){
        sum += arr[i]
    }
    let count = 0
    if(sum/k >= threshold){
        count++
    }
    for(let i = k;i<arr.length;i++){
        sum = sum - arr[i-k] + arr[i]
        if(sum/k >= threshold){
            count++
        }
    }
    return count
}